import collections
class Solution(object):
    def minMovesToMakePalindrome(self, s):
        n = len(s)
        c = collections.Counter(s)
        key_1 = ''
        num_1 = 0
        for key in c:
            if c[key] % 2 == 1:
                key_1 = key
                num_1 = c[key]
        ans = 0
        accumulated = 0
        final_id = -1
        p = [0] * n
        i = 0
        last_j = n - 1
        if num_1 == 1 and s[last_j] == key_1:
            p[last_j] = 1
            last_j -= 1
            num_1 = 0
            final_id = n - 1
        j = last_j
        t = 0
        while i < j:
            if p[i] == 1:
                i += 1
            else:
                if p[j] == 1:
                    j -= 1
                else:
                    if num_1 == 1 and p[i] == 0 and s[i] == key_1:
                        final_id = accumulated
                        p[i] = 1
                        i += 1
                    else:
                        if s[i] == s[j]:
                            p[i] = 1
                            p[j] = 1
                            ans += t
                            t = 0
                            if s[i] == key_1:
                                num_1 -= 2
                            accumulated += 1
                            j = last_j
                            while i < j and p[j] == 1:
                                last_j -= 1
                                j = last_j
                            if num_1 == 1 and p[last_j] == 0 and s[last_j] == key_1:
                                p[last_j] = 1
                                final_id = n - 1 - accumulated
                                last_j -= 1
                            i += 1
                        else:
                            j -= 1
                            t += 1
        if final_id == -1:
            return ans
        else:
            return ans + abs(n // 2 - final_id)




data = Solution()
s = "skwhhaaunskegmdtutlgtteunmuuludii"
print(data.minMovesToMakePalindrome(s))
s = "lwetelt"
print(data.minMovesToMakePalindrome(s))
s = "scpcyxprxxsjyjrww"
print(data.minMovesToMakePalindrome(s))
s = "ccyxjyj"
print(data.minMovesToMakePalindrome(s))